<template>
  <div class="processPDF">
    <div>
      <div class="processPDF-a4" v-if="form" id="printMeP">
        <div style="height: 286mm">
          <div class="processPDF-a4-title">
            <img
              style="width: 30px; height: 30px; margin-right: 10px"
              src="../../../assets/images/logossy.png"
            />
            <div>大货产品制作标准指导书</div>
          </div>
          <div class="processPDF-a4-table">
            <div class="processPDF-a4-table-one">
              <div class="processPDF-a4-table-one-left">
                <el-image
                  class="processPDF-a4-table-one-left-img"
                  :src="form.wear_image[0]"
                  :preview-src-list="form.wear_image"
                  fit="contain"
                ></el-image>
              </div>
              <div class="processPDF-a4-table-one-right">
                <div class="processPDF-a4-table-one-right-text">
                  <div>
                    {{ form.type_no }}
                  </div>
                  <div>品名：{{ form.type_name }}</div>
                </div>
                <div class="processPDF-a4-table-one-right-text1">
                  <div>
                    {{ form.is_gif == 1 ? "赠品" : "非赠品" }}
                  </div>
                  <div>
                    {{ form.is_perform == 1 ? "演出服" : "非演出服" }}
                  </div>
                  <div>
                    <!-- 更新人：{{
                    (form.log_list.lenght && form.log_list[0].username) ||
                    "暂无"
                  }} -->
                    工艺师：{{ form.add_user || "暂无" }}
                  </div>
                  <div>
                    更新时间：{{
                      (form.log_list.lenght && form.log_list[0].createtime) ||
                      "暂无"
                    }}
                  </div>
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div class="leftHeight">生产缝制工艺要求</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div class="processPDF-a4-table-two-right-text">
                  用针型号针距缝份:
                  {{
                    (form.production_sewing_process_requirements &&
                      form.production_sewing_process_requirements.stitch) ||
                    "暂无"
                  }}
                </div>
                <div class="processPDF-a4-table-two-right-text">
                  粘衬部位:
                  {{
                    (form.production_sewing_process_requirements &&
                      form.production_sewing_process_requirements.lining) ||
                    "暂无"
                  }}
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>唛头位置</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div
                  class="processPDF-a4-table-two-right-text"
                  v-if="form.mark_position"
                >
                  {{ form.mark_position.type == 5 ? "常规腰" : "主唛" }}：{{
                    form.mark_position.main
                  }}
                </div>
                <div
                  class="processPDF-a4-table-two-right-text"
                  v-if="form.mark_position"
                >
                  {{ form.mark_position.type == 5 ? "牛筋腰" : "洗唛" }}：{{
                    form.mark_position.second
                  }}
                </div>
              </div>
            </div>
            <div
              class="processPDF-a4-table-two"
              v-if="form.sample_clothes_modification_comments"
            >
              <div class="leftText">
                <div>样衣修改意见</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div class="processPDF-a4-table-two-right-text">
                  {{ form.sample_clothes_modification_comments }}
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>锁定要求</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div
                  class="processPDF-a4-table-two-right-text rightrequirements"
                >
                  <div
                    v-for="(item, index) in form.requirements_for_locking_nails"
                    :key="index"
                    style="margin-bottom: 5px"
                  >
                    要求{{ index + 1 }}：{{ item.title }}
                  </div>
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>特殊工艺要求</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div
                  class="processPDF-a4-table-two-right-text rightrequirements"
                >
                  <div
                    v-for="(item, index) in form.special_process_requirements"
                    :key="index"
                    style="margin-bottom: 5px"
                  >
                    要求{{ index + 1 }}：{{ item.title }}
                  </div>
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>包装规格要求</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div
                  class="processPDF-a4-table-two-right-text rightrequirements"
                >
                  <div
                    v-for="(
                      item, index
                    ) in form.packaging_specification_requirements"
                    :key="index"
                    style="margin-bottom: 5px"
                  >
                    要求{{ index + 1 }}：{{ item.title }}
                  </div>
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>裁剪要求</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div class="processPDF-a4-table-two-right-text">
                  {{ form.cutting_requirements }}
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>后道工序</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div class="processPDF-a4-table-two-right-text">
                  {{ form.subsequent_process }}
                </div>
              </div>
            </div>
            <div class="processPDF-a4-table-two">
              <div class="leftText">
                <div>验收标准</div>
              </div>
              <div class="processPDF-a4-table-two-right">
                <div class="processPDF-a4-table-two-right-text">
                  {{ form.acceptance_criteria }}
                </div>
              </div>
            </div>
          </div>
        </div>
        <div
          v-for="(item, index) in form.process_instruction"
          :key="index"
          style="min-height: 286mm"
        >
          <div class="processPDF-a4-title">
            <img
              style="width: 30px; height: 30px; margin-right: 10px"
              src="../../../assets/images/logossy.png"
              alt=""
            />
            <div>大货产品制作标准指导书</div>
          </div>
          <div class="processPDF-a4-table" style="border-top: 0">
            <div class="processPDF-a4-table-three" style="border-top: 0">
              <div class="processPDF-a4-table-three-left">
                <div class="processPDF-a4-table-three-left-imglabel">
                  <img :src="item.img" alt="" />
                  <div
                    class="processPDF-a4-table-three-left-imglabel-label"
                    v-for="(e, idx) in item.labels"
                    :key="idx"
                    :style="{ top: e.y + 'px', left: e.x + 'px' }"
                    @click.stop
                  >
                    {{ idx + 1 }}
                  </div>
                </div>
              </div>

              <div class="processPDF-a4-table-three-right">
                <div style="margin-bottom: 10px">
                  图片名称：{{ item.title }}
                </div>
                <div
                  class="processPDF-a4-table-three-right-content"
                  v-for="(e, idx) in item.labels"
                  :key="idx"
                >
                  <div>{{ idx + 1 }}</div>
                  <div v-html="e.content"></div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div style="min-height: 286mm">
          <div class="processPDF-a4-title">
            <img
              style="width: 30px; height: 30px; margin-right: 10px"
              src="../../../assets/images/logossy.png"
              alt=""
            />
            <div>大货产品制作标准指导书</div>
          </div>
          <div class="processPDF-a4-table">
            <div class="processPDF-a4-table-two">
              <div class="leftText" style="border-top: 0">
                <div class="leftGyxjt">工艺细节图</div>
              </div>
              <div class="processPDF-a4-table-two-right" style="border-top: 0">
                <div class="processPDF-a4-table-two-right-image">
                  <el-image
                    v-for="(item, index) in form.detail_drawing"
                    :preview-src-list="[item.url]"
                    :key="index"
                    :src="item.url"
                    fit="contain"
                  ></el-image>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div style="min-height: 286mm">
          <div class="processPDF-a4-title">
            <img
              style="width: 30px; height: 30px; margin-right: 10px"
              src="../../../assets/images/logossy.png"
              alt=""
            />
            <div>大货产品制作标准指导书</div>
          </div>
          <div class="processPDF-a4-table">
            <div class="processPDF-a4-table-two">
              <div class="leftText" style="border-top: 0">
                <div class="leftGyxjt">可撕标图示</div>
              </div>
              <div class="processPDF-a4-table-two-right" style="border-top: 0">
                <div class="processPDF-a4-table-two-right-image">
                  <el-image
                    style="width: 150mm; height: 100mm"
                    v-if="form.tearable_label_img"
                    :preview-src-list="[form.tearable_label_img]"
                    :src="form.tearable_label_img"
                    fit="contain"
                  ></el-image>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="processPDF-button">
        <div>
          <el-button type="primary" v-print="'#printMeP'">下载</el-button>
        </div>
        <!-- <div>
          <el-button type="primary" @click="onEdit">编辑</el-button>
        </div> -->
        <div>
          <el-button
            type="danger"
            v-if="process_sheet_status == 1"
            @click="onIs(type_no, 0)"
            >解锁</el-button
          >
          <el-button
            type="primary"
            v-if="process_sheet_status == 0"
            @click="onIs(type_no, 1)"
            >锁定</el-button
          >
        </div>
      </div>
      <div style="margin-left: 30px">
        <div style="font-size: 18px; font-weight: 600; margin-bottom: 20px">
          绣花推码图
        </div>
        <tmt
          :tm_img="tm_img"
          :type_no="type_no"
          :process_sheet_status="process_sheet_status"
        ></tmt>
      </div>
    </div>
  </div>
</template>

<script>
import {
  postAdminOperateLookProcess_sheet,
  postAdminOperateSetlocking,
} from "@/api";
import tmt from "./tmt.vue";
export default {
  components: {
    tmt,
  },
  props: {
    type_no: "",
    process_sheet_status: "",
  },
  data() {
    return {
      form: "",
      tm_img: [],
    };
  },
  mounted() {
    this.postAdminOperateLookProcess_sheet(this.type_no);
  },
  methods: {
    async onIs(type_no, status) {
      let obj = {
        type_no: type_no,
        type: 2,
        status: status,
      };
      this.$confirm(`确定${status == 0 ? "解锁" : "锁定"}`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          try {
            await postAdminOperateSetlocking(obj);
            this.process_sheet_status = status;
          } catch (error) {}
        })
        .catch(() => {});
    },
    onEdit() {
      let { type_no } = this;
      this.$router.push({
        name: "ProcessMaintenanceProcessedit",
        query: { type_no },
      });
    },
    onExportPDF() {
      // htmlToPdf.getPdf(
      //   `<div>大货产品制作标准指导书</div>`,
      //   "#pdfDom"
      // );
    },
    async postAdminOperateLookProcess_sheet(type_no) {
      let { form } = this;
      let obj = {
        type_no,
      };
      let res = await postAdminOperateLookProcess_sheet(obj);
      let formobj = Object.assign(form, res.data);
      this.tm_img = res.data.tm_img || [];
      this.form = formobj;
    },
  },
};
</script>

<style lang="scss" scoped>
.processPDF {
  padding-bottom: 10px;
  display: inline-block;

  > div {
    display: flex;

    .processPDF-button {
      width: 100%;
      // background: #efefef;
      border-left: 1px solid #efefef;
      padding-left: 100px;
      margin-left: 90px;
      display: flex;
      flex-direction: column;
      padding-top: 50px;

      > div {
        margin-top: 20px;
      }
    }
  }
}

.rightrequirements {
  flex-direction: column;
  text-align: left;

  > div {
    width: 100%;
  }
}

.leftHeight {
  // height: 80mm;
  // line-height: 80mm;
}

.leftTbzy {
  height: 40mm;
  line-height: 40mm;
}

.leftGyxjt {
  height: 120mm;
  line-height: 120mm;
}

.leftText {
  font-size: 16px;
  width: 40mm;
  border-right: 0.1mm solid #000000;
  border-top: 0.1mm solid #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;

  > div {
    // width: 30mm;
    font-weight: 600;
    text-align: center;
  }
}

.processPDF-a4 {
  background: #ffffff;
  width: 210mm;
  font-size: 16px;
  padding: 0 5mm;
  box-sizing: border-box;
  .processPDF-a4-title {
    height: 20mm;
    line-height: 20mm;
    font-size: 26px;
    font-weight: 800;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
  }

  .processPDF-a4-table {
    width: 200mm;
    border: 0.1mm solid #000000;
    font-size: 16px;
    line-height: 24px;

    .processPDF-a4-table-one {
      display: flex;

      .processPDF-a4-table-one-left {
        width: 40mm;
        height: 40mm;
        border-right: 0.1mm solid #000000;
        display: flex;
        justify-content: center;
        align-items: center;

        .processPDF-a4-table-one-left-img {
          width: 30mm;
          height: 30mm;
        }
      }

      .processPDF-a4-table-one-right {
        width: 160mm;

        .processPDF-a4-table-one-right-text {
          width: 160mm;
          height: 20mm;
          display: flex;

          > div:nth-child(1) {
            width: 40mm;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            border-right: 0.1mm solid #000000;
          }

          > div:nth-child(2) {
            width: 120mm;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
          }
        }
        .processPDF-a4-table-one-right-text1 {
          width: 160mm;
          height: 20mm;
          display: flex;

          > div:nth-child(1) {
            width: 20mm;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            border-right: 0.1mm solid #000000;
          }
          > div:nth-child(2) {
            width: 20mm;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            border-right: 0.1mm solid #000000;
          }
          > div:nth-child(3) {
            width: 50mm;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            border-right: 0.1mm solid #000000;
          }
          > div:nth-child(4) {
            width: 70mm;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
          }
        }
        > div:not(:nth-last-child(1)) {
          border-bottom: 1px solid #000000;
        }
      }
    }

    .processPDF-a4-table-two {
      display: flex;

      .processPDF-a4-table-two-left {
        width: 40mm;
        border-right: 0.1mm solid #000000;
        border-top: 0.1mm solid #000000;

        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;

        > div {
          width: 30mm;
          font-weight: 600;
        }
      }

      .processPDF-a4-table-two-right {
        width: 161mm;
        border-top: 1px solid #000000;
        display: flex;
        flex-direction: column;
        font-size: 16px;

        > div {
          box-sizing: border-box;
          word-break: break-all;
          width: 160mm;
          height: 100%;
          display: flex;
          align-items: center;
          // justify-content: center;
          padding: 2mm;
        }

        > div:not(:nth-last-child(1)) {
          border-bottom: 1px solid #000000;
        }

        .processPDF-a4-table-two-right-textimg {
          display: flex;

          > .el-image {
            width: 100px;
            margin-right: 10px;
          }
        }

        .processPDF-a4-table-two-right-image {
          display: flex;
          flex-wrap: wrap;

          > .el-image {
            width: 72mm;
            height: 72mm;
            margin-right: 5mm;
            margin-bottom: 5mm;
          }
        }
      }
    }

    .processPDF-a4-table-three {
      border-top: 0.1mm solid #000000;

      // display: flex;
      .processPDF-a4-table-three-left {
        padding: 10px;
        // border-right: 0.1mm solid #000000;
        width: 100%;
        display: flex;
        align-items: center;
        border-top: 0.1mm solid #000000;
        border-bottom: 0.1mm solid #000000;
        display: flex;
        align-items: center;
        justify-content: center;

        .processPDF-a4-table-three-left-imglabel {
          width: 600px;
          height: 300px;
          position: relative;

          .processPDF-a4-table-three-left-imglabel-label {
            width: 20px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            background: red;
            color: #ffffff;
            border-radius: 50%;
            position: absolute;
            font-size: 12px;
          }

          > img {
            height: 300px;
          }
        }
      }

      .processPDF-a4-table-three-right {
        width: 100%;
        padding: 10px;
        display: flex;
        flex-direction: column;
        justify-content: center;

        .processPDF-a4-table-three-right-content {
          display: flex;
          align-items: center;
          margin-bottom: 6px;

          > div:nth-child(1) {
            font-size: 14px;
            margin-right: 10px;
            width: 20px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            border: 1px solid #000000;
            border-radius: 20px;
            margin-top: 6px;
          }

          > div:nth-child(2) {
            width: calc(200mm - 50px);
          }
        }
      }
    }
  }
}
</style>